import { Env } from "#Config/base.js"
import path from 'path'
// 获取当前文件的目录
// 获取跟目录
const rootPath = path.join(process.cwd(), 'storage', 'db')

const koaDB = path.join(rootPath, 'koa.db')


// 初始化 环境变量
Env

export default {
    connect: process.env.DB_CONNECT || "koa",
    defaultDB: koaDB.startsWith('/')? koaDB.slice(1): koaDB,
    connections: {
        koaMysql: {
            "dialect": "mysql",
            "username": process.env.DB_USERNAME || "root",
            "password": process.env.DB_PASSWORD || "root",
            "database": "koa",
            "host": process.env.DB_HOST || "127.0.0.1",
            "port": process.env.DB_PORT || 3306,
            "logging": true,
            "pool": {
                "max": 5,
                "min": 0,
                "acquire": 30000,
                "idle": 10000
            },
        },
        "koa-test": {
            "dialect": "mysql",
            "username": process.env.DB_USERNAME || "root",
            "password": process.env.DB_PASSWORD || "root",
            "database": "koa-test",
            "host": process.env.DB_HOST || "127.0.0.1",
            "port": process.env.DB_PORT || 3306,
            "logging": true,
            "pool": {
                "max": 5,
                "min": 0,
                "acquire": 30000,
                "idle": 10000
            }
        },
        koa: {
            name: 'koa',
            dialect: "sqlite",
            storage: koaDB,
            logging: true,
            pool: {
                "max": 5,
                "min": 0,
                "acquire": 30000,
                "idle": 10000
            },
        }
    }
}
